<%-- 
    Document   : timesheet
    Created on : Nov 17, 2012, 7:44:54 AM
    Author     : Cimela
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x"%>
<html>
    <c:if test="${empty sessionScope.USER}">
        <jsp:forward page="index.jsp"/>
    </c:if>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Timesheet</title>
    </head>
    <body>
        <h1>Timesheet</h1>
        <form action="TimesheetController" method="POST">
            From: <input type="text" name="txtFrom"/>
            To:   <input type="text" name="txtTo"/>
            Project:
            <c:set var="pjlist" value="${sessionScope.listPj}"  ></c:set>
            <select name="cbProject" style ="width: 150px">
                <option value="All">All</option>
                <c:import url="/WEB-INF/project.xml" var="xml"/>
                <x:parse var="doc" xml="${xml}" scope="session"/>
                <x:forEach var="proj" select="$doc//name">
                    <option value="$proj" ><x:out select="$proj"/></option>
                </x:forEach>
            </select>
            Status:
            <select name="cbStatus" >
                <option value="All">All</option>
                <option value="approved">approved</option>
                <option value="unapproved">unapproved</option>
                <option value="rejected">rejected</option>
            </select>
            <input type="submit" name="btAction" value="Search" />
        </form>
        <br/>

        <c:set var = "info" value="${requestScope.TSheet}"/>
        <c:if test ="${not empty info}">
            <form action="TimesheetController" >
                <table border="1">
                    <thead>
                        <tr>
                            <th></th>
                            <th>Date</th>
                            <th>Description</th>
                            <th>Project</th>
                            <th>Duration</th>
                            <th>Status</th>
                        </tr>
                    </thead>
                    <tbody>
                        <c:forEach var="timesheet" items="${info}">
                            <tr>
                                <td width="15px"> <input type="checkbox" name="chkChoose" value="${timesheet.id}"/>
                                     <input type="hidden" name="txtID" value="${timesheet.id}" /> </td>
                                <td width="100px" > ${timesheet.datetime} </td>
                                <td width="300px" > ${timesheet.description} </td>
                                <td width="200px" > ${timesheet.project} </td>
                                <td width="20px"  > ${timesheet.duration} </td>
                                <td width="80px"  > ${timesheet.status} </td>
                            </tr>
                        </c:forEach>
                    </tbody>
                </table>
                <br/>
                <input type="submit" name="btAction" value="Update"/>
                <input type="submit" name="btAction" value="Delete"/>
            </form>
        </c:if>
    </body>
</html>
